﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
        public static T[] Randomize<T>(T[] items)
        {
            List<T> itemList = new List<T>(items);
            return Randomize<T>(itemList).ToArray();
        }
        public static List<T> Randomize<T>(List<T> items)
        {
            List<T> randomList = new List<T>();
            Random r = new Random();
            Int32 randomIndex = 0;
            while (items.Count > 0)
            {
                randomIndex = r.Next(0, items.Count);
                randomList.Add(items[randomIndex]);
                items.RemoveAt(randomIndex);
            } return randomList;
        }
    }
}
